% igeti.m

% 2/27/95
% creates i-vector and ic-veector
% Suppose,
% icpsr = 101 102 103 101 102 104, then
%     i = 1 2 3 1 2 4
%    ic = 101 102 103 104

ic = [];
i=zeros(Ns,1);
i(1) = 1;
ic=[ic;icpsr(1)];

for s=2:Ns,

  % check if icpsr(s) is on ic
  indi = find(ic == icpsr(s));

  %if on ic
  if length(indi) > 0,
    i(s) = indi(1); % = 1st occurrenc of icpsr(s) on ic
  else % if not on ic
    %put on ic
    ic = [ic;icpsr(s)];
    i(s) = length(ic);
  end;
end;
